﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;

namespace Lm.Common.ExtensionMethods
{
    public static class NameValueCollectionExt
    {
        public static string ToQueryString(this NameValueCollection list)
        {
            StringBuilder sb = new StringBuilder();
            foreach (string i in list)
            {
                sb.Append(System.Web.HttpUtility.UrlEncode(i));
                sb.Append('=');
                sb.Append(System.Web.HttpUtility.UrlEncode(list[i]));
                sb.Append('&');
            }
            return sb.ToString().TrimEnd('&');
        }
    }
}
